﻿//AndroidPluginManager.cs

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class AndroidPluginManager : MonoBehaviour
{
	public static AndroidPluginManager _instance;
	private AndroidJavaObject curActivity;
	private AndroidJavaClass firstPluginJc;
	
	public string strLog = "Westwood Forever Unity3D Android Plugin Sample";


	public static AndroidPluginManager GetInstance()
	{
		if( _instance == null )
		{
			_instance = new GameObject("AndroidPluginManager").AddComponent<AndroidPluginManager>();    
		}
		
		return _instance;
	}

	void Awake()
	{

		firstPluginJc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
		curActivity = firstPluginJc.GetStatic<AndroidJavaObject>("currentActivity");

	}
	
	public void CallAndroid(string strMsg)
	{
		//자바 호출
	//	curActivity.Call("CallAndroid_U", strMsg);
	}

	public void CallAndroid_Show()
	{
		Debug.Log("Show StatusBar");
		curActivity.Call ("ShowStatusBar", true);

	}

	public void CallAndroid_Hide()
	{
		Debug.Log("Hide StatusBar");
		curActivity.Call ("ShowStatusBar", false);

	}

	public void CallAndroid_Video(string videoURL)
	{
		Debug.Log("Play Video");
		//videoURL = "http://101.201.148.166/VR_AR/uploads/video/video-1024x512.mp4";
		curActivity.Call ("PlayVideo", videoURL);
	}

	public void CallAndroid_Internet(string strURL)
	{
		Debug.Log("Play Internet");
		//strURL = "http://m.naver.com";
		curActivity.Call ("PlayInternet", strURL);
	}

	protected void SetLog(string strLog)
	{
		this.strLog = strLog;
	}
}